<template>
    <a-card :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
            <a-form layout="inline" @keyup.enter.native="searchQuery">
                <a-row :gutter="24">
                    <a-col :xl="6" :lg="7" :md="8" :sm="24">
                        <a-form-item label="车牌号">
                            <j-input placeholder="请输入车牌号" v-model="queryParam.plateNo"></j-input>
                        </a-form-item>
                    </a-col>
                    <a-col :xl="10" :lg="11" :md="12" :sm="24">
                        <a-form-item label="登记时间">
                            <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始时间"
                                class="query-group-cust" v-model="queryParam.createTime_begin"></j-date>
                            <span class="query-group-split-cust"></span>
                            <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束时间"
                                class="query-group-cust" v-model="queryParam.createTime_end"></j-date>
                        </a-form-item>
                    </a-col>
                    <template v-if="toggleSearchStatus">
                        <a-col :xl="6" :lg="7" :md="8" :sm="24">
                            <a-form-item label="挂车号">
                                <j-input placeholder="请输入挂车号" v-model="queryParam.trailerNo"></j-input>
                            </a-form-item>
                        </a-col>
                        <a-col :xl="6" :lg="7" :md="8" :sm="24">
                            <a-form-item label="司机姓名">
                                <j-input placeholder="请输入司机姓名" v-model="queryParam.driverName"></j-input>
                            </a-form-item>
                        </a-col>
                        <a-col :xl="6" :lg="7" :md="8" :sm="24">
                            <a-form-item label="手机号">
                                <j-input placeholder="请输入手机号" v-model="queryParam.phoneNum"></j-input>
                            </a-form-item>
                        </a-col>
                        <a-col :xl="6" :lg="7" :md="8" :sm="24">
                            <a-form-item label="所属运输企业名称">
                                <j-input placeholder="请输入所属运输企业名称" v-model="queryParam.fleet"></j-input>
                            </a-form-item>
                        </a-col>
                        <a-col :xl="6" :lg="7" :md="8" :sm="24">
                            <a-form-item label="审核状态">
                                <j-dict-select-tag placeholder="请选择审核状态" v-model="queryParam.auditStatus"
                                    dictCode="audit_status" />
                            </a-form-item>
                        </a-col>
                        <a-col :xl="10" :lg="11" :md="12" :sm="24">
                            <a-form-item label="磅单上传时间">
                                <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始时间"
                                    class="query-group-cust" v-model="queryParam.poundListTime_begin"></j-date>
                                <span class="query-group-split-cust"></span>
                                <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束时间"
                                    class="query-group-cust" v-model="queryParam.poundListTime_end"></j-date>
                            </a-form-item>
                        </a-col>
                    </template>
                    <a-col :xl="6" :lg="7" :md="8" :sm="24">
                        <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                            <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                            <a-button type="primary" @click="searchReset" icon="reload"
                                style="margin-left: 8px">重置</a-button>
                            <a @click="handleToggleSearch" style="margin-left: 8px">
                                {{ toggleSearchStatus ? '收起' : '展开' }}
                                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
                            </a>
                        </span>
                    </a-col>
                </a-row>
            </a-form>
        </div>
        <!-- 查询区域-END -->

        <!-- 操作按钮区域 -->
        <div class="table-operator">
            <a-button type="primary" icon="download" @click="handleExportXls('液袋台账')">导出液袋台账</a-button>
        </div>

        <!-- table区域-begin -->
        <div>
            <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
                <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
                    selectedRowKeys.length }}</a>项
                <a style="margin-left: 24px" @click="onClearSelected">清空</a>
            </div>

            <a-table ref="table" size="middle" :scroll="{ x: true }" bordered rowKey="id" :columns="columns"
                :dataSource="dataSource" :pagination="ipagination" :loading="loading"
                :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
                class="j-table-force-nowrap" @change="handleTableChange">

                <span slot="auditStatus" slot-scope="text">
                    <a-tag v-if="text == 1" color="geekblue">新登记</a-tag>
                    <a-tag v-if="text == 2" color="green">初步审核通过</a-tag>
                    <a-tag v-if="text == 3" color="volcano">初步审核驳回</a-tag>
                    <a-tag v-if="text == 4" color="green">二次审核通过</a-tag>
                    <a-tag v-if="text == 5" color="volcano">二次审核驳回</a-tag>
                    <a-tag v-if="text == 6" color="green">查验合格</a-tag>
                    <a-tag v-if="text == 7" color="volcano">查验不合格</a-tag>
                    <a-tag v-if="text == 8" color="green">品质检查合格</a-tag>
                    <a-tag v-if="text == 9" color="volcano">品质检查不合格</a-tag>
                    <a-tag v-if="text == 10" color="orange">铅封未上传</a-tag>
                    <a-tag v-if="text == 11" color="green">铅封已上传</a-tag>
                    <a-tag v-if="text == 12" color="orange">磅单待上传</a-tag>
                    <a-tag v-if="text == 13" color="green">已完成</a-tag>
                    <a-tag v-if="text == 14" color="#444">黑名单</a-tag>
                    <a-tag v-if="text == 15" color="volcano">已过期</a-tag>
                    <a-tag v-if="text == 16" color="orange">入场铅封未上传</a-tag>
                    <a-tag v-if="text == 17" color="orange">入场铅封待修改</a-tag>
                    <a-tag v-if="text == 18" color="volcano">入场铅封不合格</a-tag>
                </span>

                <template slot="htmlSlot" slot-scope="text">
                    <div v-html="text"></div>
                </template>
                <template slot="imgSlot" slot-scope="text">
                    <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
                    <viewer :options="options" v-else class="viewer" ref="viewer">
                        <img src="../../../assets/yulan.png" :data-source="getImgView(text)" height="25px" alt=""
                            style="max-width: 80px; font-size: 12px; font-style: italic" />
                    </viewer>
                </template>
                <template slot="fileSlot" slot-scope="text">
                    <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
                    <a-button v-else :ghost="true" type="primary" icon="download" size="small"
                        @click="downloadFile(text)">
                        下载
                    </a-button>
                </template>

                <span slot="action" slot-scope="text, record">
                    <a @click="handleDetail(record)">详情</a>
                </span>

            </a-table>
        </div>

        <tanker-registration-modal ref="modalForm" @ok="modalFormOk"></tanker-registration-modal>
    </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import TankerRegistrationModal from './modules/TankerRegistrationModal'
import { postAction } from "@api/manage";
import 'viewerjs/dist/viewer.css'

export default {
    name: 'TakeDeliveryList',
    mixins: [JeecgListMixin, mixinDevice],
    components: {
        TankerRegistrationModal,
    },
    data() {
        return {
            options: { url: 'data-source' },
            description: '提货罐车登记表管理页面',
            imgSrc: [],
            // 表头
            columns: [
                {
                    title: '#',
                    dataIndex: '',
                    key: 'rowIndex',
                    width: 60,
                    align: "center",
                    customRender: function (t, r, index) {
                        return parseInt(index) + 1;
                    }
                },
                {
                    title: '发货企业名称',
                    align: "center",
                    dataIndex: 'deliverCompany'
                },
                {
                    title: '发货时间',
                    align: "center",
                    dataIndex: 'leadSealingTime'
                },
                {
                    title: '车牌号',
                    align: "center",
                    dataIndex: 'plateNo'
                },
                {
                    title: '挂车号',
                    align: "center",
                    dataIndex: 'trailerNo'
                },
                {
                    title: '司机姓名',
                    align: "center",
                    dataIndex: 'driverName'
                },
                {
                    title: '所属运输企业名称',
                    align: "center",
                    dataIndex: 'fleet'
                },
                // {
                //     title: '重量(吨)',
                //     align: "center",
                //     dataIndex: 'weight'
                // },
                {
                    title: '产品名称',
                    align: "center",
                    dataIndex: 'productionName'
                },
                {
                    title: '发货人员',
                    align: "center",
                    dataIndex: 'leadSealingName'
                },
                {
                    title: '查验人员',
                    align: "center",
                    dataIndex: 'surveyorName'
                },
                {
                    title: '验收结果',
                    align: "center",
                    dataIndex: 'checkResult'
                },
                {
                    title: '收货企业名称',
                    align: "center",
                    dataIndex: 'receiptCompany'
                },
                {
                    title: '备注',
                    align: "center",
                    dataIndex: 'rejectReason'
                },
                {
                    title: '操作',
                    dataIndex: 'action',
                    align: "center",
                    fixed: "right",
                    width: 147,
                    scopedSlots: { customRender: 'action' }
                }
            ],
            url: {
                list: "/tankerRegistration/tankerRegistration/list?transportMode=3",
                exportXlsUrl: "/tankerRegistration/tankerRegistration/getLiquidBagLedger",

            },
            dictOptions: {},
            superFieldList: [],
            gpsShow: false,
            trackArray: {},
            parkArray: [],
            GPSbegin: undefined,
            GPSend: undefined,
            hour: 72,
            registration: {},
            gpsModalLoading: false,
            stepsShow: false,
            current: 0,
            status: 'wait',
            formattedNow: '',
            formattedTomorrow: '',
        }
    },
    created() {
        this.getSuperFieldList();
    },
    computed: {
        importExcelUrl: function () {
            return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
        },
    },
    methods: {
        initDictConfig() {
        },
        getSuperFieldList() {
            let fieldList = [];
            fieldList.push({ type: 'datetime', value: 'createTime', text: '创建日期' })
            fieldList.push({ type: 'string', value: 'plateNo', text: '车牌号', dictCode: '' })
            fieldList.push({ type: 'string', value: 'trailerNo', text: '挂车号', dictCode: '' })
            fieldList.push({ type: 'string', value: 'driverName', text: '司机姓名', dictCode: '' })
            fieldList.push({ type: 'string', value: 'idCard', text: '身份证号', dictCode: '' })
            fieldList.push({ type: 'string', value: 'phoneNum', text: '手机号', dictCode: '' })
            fieldList.push({ type: 'string', value: 'healthCertificate', text: '健康证', dictCode: '' })
            fieldList.push({ type: 'date', value: 'healthCertificateDate', text: '健康证有效期' })
            fieldList.push({ type: 'string', value: 'fleet', text: '所属运输企业名称', dictCode: '' })
            fieldList.push({ type: 'int', value: 'isEdibleOilLabel', text: '车体是否有食用油专用标签', dictCode: 'is_edible_oil_label' })
            fieldList.push({ type: 'string', value: 'lastTimeUnloadingCompanyName1', text: '前一载卸货公司', dictCode: '' })
            fieldList.push({ type: 'string', value: 'lastTimeUnloadingCompanyName2', text: '前二载卸货公司', dictCode: '' })
            fieldList.push({ type: 'string', value: 'lastTimeUnloadingCompanyName3', text: '前三载卸货公司', dictCode: '' })
            fieldList.push({ type: 'string', value: 'lastTimeUnloadingGoodsName1', text: '前一载卸车货品名称', dictCode: '' })
            fieldList.push({ type: 'string', value: 'lastTimeUnloadingGoodsName2', text: '前二载卸车货品名称', dictCode: '' })
            fieldList.push({ type: 'string', value: 'lastTimeUnloadingGoodsName3', text: '前三载卸车货品名称', dictCode: '' })
            fieldList.push({ type: 'date', value: 'lastTimeUnloadingDate1', text: '前一载卸货日期' })
            fieldList.push({ type: 'date', value: 'lastTimeUnloadingDate2', text: '前二载卸货日期' })
            fieldList.push({ type: 'date', value: 'lastTimeUnloadingDate3', text: '前三载卸货日期' })
            fieldList.push({ type: 'string', value: 'lastTimeUnloadingPhotos', text: '三载卸货照片', dictCode: '' })
            fieldList.push({ type: 'date', value: 'lastTimeCleaningDate', text: '上次清洗时间' })
            fieldList.push({ type: 'string', value: 'lastTimeCleaningPhotos', text: '上次清洗证明和发票', dictCode: '' })
            fieldList.push({ type: 'int', value: 'transportStatus', text: '运输状态', dictCode: 'transport_status' })
            fieldList.push({ type: 'int', value: 'auditStatus', text: '审核状态', dictCode: 'audit_status' })
            fieldList.push({ type: 'int', value: 'entryStatus', text: '入场状态', dictCode: 'entry_status' })
            fieldList.push({ type: 'string', value: 'vehicle45Photo', text: '车头照片', dictCode: '' })
            fieldList.push({ type: 'string', value: 'back45Photo', text: '车尾照片', dictCode: '' })
            fieldList.push({ type: 'string', value: 'tankPhoto', text: '罐内照片', dictCode: '' })
            fieldList.push({ type: 'string', value: 'oilDischargePortPhoto', text: '卸油口照片', dictCode: '' })
            fieldList.push({ type: 'string', value: 'leadSealingPic', text: '铅封照片', dictCode: '' })
            fieldList.push({ type: 'int', value: 'isOdor', text: '是否异味', dictCode: 'is_odor' })
            fieldList.push({ type: 'string', value: 'auditName1', text: '初步审核人', dictCode: '' })
            fieldList.push({ type: 'datetime', value: 'auditTime1', text: '初步审核时间' })
            fieldList.push({ type: 'string', value: 'auditName2', text: '二次审核人', dictCode: '' })
            fieldList.push({ type: 'datetime', value: 'auditTime2', text: '二次审核时间' })
            fieldList.push({ type: 'string', value: 'surveyorName', text: '查验人', dictCode: '' })
            fieldList.push({ type: 'datetime', value: 'surveyorTime', text: '查验时间' })
            fieldList.push({ type: 'string', value: 'productionType', text: '产品种类', dictCode: '' })
            fieldList.push({ type: 'string', value: 'vehiclePhoto', text: '车身照片', dictCode: '' })
            fieldList.push({ type: 'string', value: 'documentation', text: '前三载证明文件', dictCode: '' })
            fieldList.push({ type: 'string', value: 'screenshot', text: 'gps截图', dictCode: '' })
            fieldList.push({ type: 'string', value: 'location', text: '报道位置', dictCode: '' })
            fieldList.push({ type: 'string', value: 'driverSign', text: '司机签字', dictCode: '' })
            fieldList.push({ type: 'string', value: 'rejectReason', text: '驳回原因', dictCode: '' })
            fieldList.push({ type: 'string', value: 'storageTankPhoto', text: '储运拍照', dictCode: '' })
            fieldList.push({ type: 'string', value: 'poundListPhoto', text: '磅单照片', dictCode: '' })
            fieldList.push({ type: 'datetime', value: 'poundListTime', text: '磅单上传时间' })
            this.superFieldList = fieldList
        },
        showSteps(record) {
            let auditStatus = record.auditStatus
            switch (auditStatus) {
                case 1:
                    this.current = 0
                    this.status = 'process'
                    break
                case 2:
                    this.current = 1
                    this.status = 'process'
                    break
                case 3:
                    this.current = 2
                    this.status = 'error'
                    break
                case 4:
                    this.current = 3
                    this.status = 'process'
                    break
                case 5:
                    this.current = 4
                    this.status = 'error'
                    break
                case 6:
                    this.current = 5
                    this.status = 'process'
                    break
                case 7:
                    this.current = 6
                    this.status = 'error'
                    break
                case 8:
                    this.current = 7
                    this.status = 'process'
                    break
                case 9:
                    this.current = 8
                    this.status = 'error'
                    break
                case 10:
                    this.current = 9
                    this.status = 'wait'
                    break
                case 11:
                    this.current = 10
                    this.status = 'process'
                    break
                case 12:
                    this.current = 11
                    this.status = 'process'
                    break
                case 13:
                    this.current = 12
                    this.status = 'finish'
                    break
            }
            this.stepsShow = true
        },
    }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>